import React, { PureComponent } from 'react'

//定义一个高阶组件
function enhanceReactProps(WrapperComponent) { 
  return props => { 
    return <WrapperComponent {...props} region="中国"></WrapperComponent>
  }
}


class Home extends PureComponent {
  render() {
    return (
      <div>
        <h2>Home：{`昵称：${this.props.nickname}  等级：${this.props.level}  区域：${this.props.region}`}</h2>
      </div>
    )
  }
}

class About extends PureComponent {
  render() {
    return (
      <div>
        <h2>About：{`昵称：${this.props.nickname}  等级：${this.props.level}  区域：${this.props.region}`}</h2>
      </div>
    )
  }
}

const EnhancedHome = enhanceReactProps(Home);
const EnhancedAbout = enhanceReactProps(About);


class App extends PureComponent {
  render() {
    return (
      <div>
        App
        <EnhancedHome nickname="codewhy" level={90}></EnhancedHome>
        <EnhancedAbout nickname="kobe" level={99}></EnhancedAbout>
      </div>
    )
  }
}


export default App
